﻿using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Diagnostics;
using System.Globalization;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;

namespace CommonUtils
{
	public abstract class BaseApp : IBaseApp
	{
		#region ctors
		public BaseApp()
		{
			AppStartTime = Common.DataTimeNow;
		}
		#endregion ctors

		#region properties
		public int ExitCode						{ get; protected set; }
		public abstract string LoggerFilename	{ get; protected set; }
		public string[] CommandlineArgs			{ get; protected set; }
		public string AppStartTime				{ get; private set; }
		public string EntryAssemblyName			{ get { return Assembly.GetEntryAssembly().GetName().Name; } }
		public string EntryAssemblyVersion		{ get { return Assembly.GetEntryAssembly().GetName().Version.ToString(); } }
		public string ExecutingAssemblyName		{ get { return Assembly.GetExecutingAssembly().GetName().Name; } }
		public string ExecutingAssemblyVersion	{ get { return Assembly.GetExecutingAssembly().GetName().Version.ToString(); } }
		public string ExecutableBuild
		{
			get
			{
				#if DEBUG 
					return "DEBUG";
				#else
					return "RELEASE";
				#endif
			}
		}
		#endregion properties

		#region methods
		public virtual string GetLoggerFilename()
		{
			return Common.PathCombine(Common.Desktop, EntryAssemblyName + Common.DataTimeNow + ".log");
		}
		
		public virtual void Init(string[] inCommandlineArgs)
		{
			CommandlineArgs = inCommandlineArgs;
		}
		public virtual void Run() { }
        public virtual void End() { }
		#endregion methods

		#region fields
		#endregion fields
	}
}